<?php

if (!defined('NV_IS_MOD_NEWS'))
    die('Stop!!!');

$blocknewsid = 2;

global $global_config, $module_name, $module_data, $module_file, $global_array_cat, $module_config, $module_info;
$array_block_news = array();


$sql = "SELECT id,  listcatid, hometext, title, alias, homeimgfile FROM `" . NV_PREFIXLANG . "_" . $module_data . "_rows` WHERE `status`= 1 AND `publtime` < " . NV_CURRENTTIME . " AND (`exptime`=0 OR `exptime`>" . NV_CURRENTTIME . ") ORDER BY `publtime` DESC LIMIT 1";

if (( $query = $db->sql_query($sql) ) !== false) {
    if (( $row = $db->sql_fetchrow($query) ) !== false) {
        $catid = end( explode( ",", $row['listcatid'] ) );
        $alias = $row['alias'];
        $id = $row['id'];
        $link = NV_BASE_SITEURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&amp;" . NV_NAME_VARIABLE . "=" . $module_name . "&amp;" . NV_OP_VARIABLE . "=" . $global_array_cat[$catid]['alias'] . "/" . $alias . "-" . $id;
        $imgurl = NV_BASE_SITEURL . NV_UPLOADS_DIR . '/' . $module_name . '/'.$row['homeimgfile'];
        $news = array();
        $news['title'] = $row['title'];
        $news['link'] = $link;
        $news['short_content'] = nv_clean60(strip_tags($row['hometext']), 300);
        $news['image'] = $imgurl;
        $xtpl = new XTemplate( "block_short_news.tpl", NV_ROOTDIR . "/themes/" . $module_info['template'] . "/modules/" . $module_file );
        $xtpl->assign( 'news', $news );
        $xtpl->parse('main');
        $content = $xtpl->text( 'main' );
    }
}
